<?php
namespace app\home\controller;

class Common extends \think\Controller
{
    public function _initialize()
    {
        //验证登录代码
        if ( session('user_id') == NULL)
        {	
        		session('url', $_SERVER['PHP_SELF']);
	        	$this->error("未登录",'home/login/login');
   		}
        
        if(!empty($user_id)){
    		$result  = db("user")->where("user_id = {$user_id}")->find();
    	}
    	else{
    		$user_id="";
    		$result=[];
            $result['user_name']="普通用户";
        }
        $this->assign("result",$result);
        //登录五分钟内不操作，登录超时
    }

}
